{{Extend "layout"}}
{{Block "title"}}{{"云备份配置"|$.T}}{{/Block}}
{{Block "breadcrumb"}}
{{Super}}
<li class="active">{{"云备份配置列表"|$.T}}</li>
{{/Block}}
{{Block "main"}}
<div class="row">
	<div class="col-md-12">
		<div class="block-flat no-padding">
			<div class="header">
				<a href="{{BackendURL}}/cloud/backup_add" class="btn btn-success pull-right">
					<i class="fa fa-plus"></i>
					{{"添加云备份配置"|$.T}}
				</a>
				<h3>{{"云备份配置列表"|$.T}}</h3>
			</div>
			<div class="content">
				<div class="table-responsive">
				<table class="table no-border hover">
					<thead class="no-border">
						<tr>
							<th style="width:50px"><strong>ID</strong></th>
							<th style="width:80px;">
								<strong>{{"启用状态"|$.T}}</strong>
							</th>
							<th><strong>{{"名称"|$.T}}</strong></th>
							<th><strong>{{"路径"|$.T}}</strong></th>
							<th style="width:70px"><strong>{{"运行结果"|$.T}}</strong></th>
							<th style="width:70px"><strong>{{"全量备份"|$.T}}</strong></th>
							<th style="width:70px"><strong>{{"文件监控"|$.T}}</strong></th>
							<th style="width:70px"><strong>{{"日志"|$.T}}</strong></th>
							<th style="width:185px"><strong>{{"时间"|$.T}}</strong></th>
							<th style="width:80px" class="text-center"><strong>{{"操作"|$.T}}</strong></th>
						</tr>
					</thead>
					<tbody class="no-border-y">
                        {{- range $k,$v := $.Stored.listData}}
						<tr>
							<td>{{$v.Id}}</td>
							<td>
							<div class="checkbox checkbox-primary no-margin-y">
								<input type="checkbox" id="checkbox-disabled-{{$k}}" value="N" class="switch-disabled" data-id="{{$v.Id}}"{{if eq $v.Disabled `N`}} checked="checked"{{end}} /> <label for="checkbox-disabled-{{$k}}">{{"启用"|$.T}}</label>
							</div>
							</td>
							<td>{{$v.Name}}</td>
							<td>{{"源路径"|$.T}}: {{$v.SourcePath}}<br />
								{{"云存储"|$.T}}: <span class="label label-default">{{$v.StorageEngine}}</span>
								{{if $v.Storage}}<span class="label label-primary">{{$v.Storage.Name}}</span>{{end}}
								{{$v.DestPath}}
							</td>
							<td>{{$v.Result}}</td>
							<td>
							{{- if $v.FullBackuping}}
							<span title="{{`备份中`|$.T}}" data-fullbackuping-id="{{$v.Id}}" class="label label-disabled" data-toggle="tooltip"><i class="fa fa-refresh fa-spin"></i></span>
							{{- else}}
							<a title="{{`启动全量备份`|$.T}}" class="label label-success" href="{{BackendURL}}/cloud/backup_start?op=full&id={{$v.Id}}" data-toggle="tooltip"><i class="fa fa-refresh"></i></a>
							{{- end}}
							</td>
							<td>
							{{- if $v.Watching}}
							<span title="{{`监控中`|$.T}}" class="label label-disabled" data-toggle="tooltip"><i class="fa fa-refresh fa-spin"></i></span>
							{{- else}}
							<a title="{{`启动监控`|$.T}}" class="label label-success" href="{{BackendURL}}/cloud/backup_start?id={{$v.Id}}" data-toggle="tooltip"><i class="fa fa-refresh"></i></a>
							{{- end}}
							</td>
							<td>
								{{- if eq $v.LogDisabled `N` -}}
								<span class="text-success">{{`开启`|$.T}}</span><br />
								<small class="text-default">{{if eq $v.LogType `all`}}{{`记录全部信息`|$.T}}{{else}}{{`仅记录报错信息`|$.T}}{{end}}</small>
								{{- else -}}
								<span class="text-danger">{{`关闭`|$.T}}</span>
								{{- end -}}
							</td>
							<td>
								{{`编辑时间`|$.T}}:
								{{- if gt $v.Updated 0 -}}
								{{(Date $v.Updated).Format "2006-01-02 15:04:05"}}
								{{- else -}}
								{{(Date $v.Created).Format "2006-01-02 15:04:05"}}
								{{- end -}}<br />
								{{`上次启动`|$.T}}:
								{{- if gt $v.LastExecuted 0 -}}
								{{(Date $v.LastExecuted).Format "2006-01-02 15:04:05"}}
								{{- else -}}
								N/A
								{{- end -}}
							</td>
							<td class="label-group">
							<a class="label label-warning" data-toggle="tooltip" title="{{`日志`|$.T}}" href="{{BackendURL}}/cloud/backup_log?backupId={{$v.Id}}"><i class="fa fa-comments-o"></i></a>
							<a class="label label-default" href="{{BackendURL}}/cloud/backup_add?copyId={{$v.Id}}" title="{{`复制`|$.T}}" data-toggle="tooltip"><i class="fa fa-copy"></i></a>
							<a title="{{`修改`|$.T}}" class="label label-primary" href="{{BackendURL}}/cloud/backup_edit?id={{$v.Id}}" data-toggle="tooltip"><i class="fa fa-pencil"></i></a>
							<a title="{{`删除`|$.T}}" class="label label-danger" href="{{BackendURL}}/cloud/backup_delete?id={{$v.Id}}" onclick="return confirm('{{`真的要删除吗？`|$.T}}');" data-toggle="tooltip"><i class="fa fa-times"></i></a>
							<a class="label label-pink" href="{{BackendURL}}/cloud/backup_restore?id={{$v.Id}}" title="{{`还原文件`|$.T}}" data-toggle="tooltip"><i class="fa fa-reply"></i></a>
							</td>
						</tr>
                        {{end}}
					</tbody>
				</table>		
				</div>
				{{- $.Stored.pagination.Render}}
			</div>
		</div>				
	</div>
</div>
{{/Block}}
{{Block "footer"}}
<script>
$(function(){
	App.bindSwitch('input.switch-disabled','click','cloud/backup_edit');
	$('span[data-fullbackuping-id]').each(function(){
		var fn=function(a){
			var id=$(a).data('fullbackuping-id');
			$.get(BACKEND_URL+'/cloud/backup',{checkStatus:'fullbackup',id:id},function(r){
				if(r.Code!=1) return App.message({text:r.Info,type:'error'});
				if(r.Data.backuping) {
					window.setTimeout(function(){fn(a)},2000);
				}else{
					$(a).replaceWith('<a title="{{`启动全量备份`|$.T}}" class="label label-success" href="{{BackendURL}}/cloud/backup_start?op=full&id='+id+'" data-toggle="tooltip"><i class="fa fa-refresh"></i></a>');
				}
			},'json')
		};
		fn(this);
	})
});
</script>
{{/Block}}